import React from 'react';
import ModalForm from '../../../components/modalForm';
import { minRule } from '../../../utils/index';

export default function Editor(props) {
    const { isNew } = props;
    let config = {};
    if (!isNew) {
        config.id = {
            label: 'ID',
            input: {
                disabled: true,
            },
        };
    }
    const requiredRule = {
        required: true,
        message: '必填项',
    };
    const numberRule = {
        type: 'number',
        message: '请输入数字',
    };
    config = {
        ...config,
        val2: {
            label: '单价(元)',
            type: 'number',
            fd: {
                rules: [requiredRule, numberRule, minRule()],
            },
        },
        val1: {
            label: '时长(分钟)',
            type: 'number',
            fd: {
                rules: [requiredRule, numberRule, minRule(1)],
            },
        },
    };

    return (
        <ModalForm
            {
                ...{
                    ...props,
                    config
                }
            }
        />
    );
}
